/****************************************************************************
**
** Copyright (C) 2010 Richard Steffen and/or its subsidiary(-ies).
** All rights reserved.
** Contact: rsteffen@messbild.de, rsteffen@uni-bonn.de
**
** Observe the License Information
**
****************************************************************************/

#include "main.h"

#include <QApplication>

#include "QColorRampEditor.h"

int main(int argc, char* argv[])
{
    
    QApplication app(argc, argv);
    DrawIm* dimg = new DrawIm();

    QVector<QPair<qreal, QColor> > initramp;
    initramp.push_back(QPair<qreal, QColor>(-100.0,QColor(255,0,0)));
    initramp.push_back(QPair<qreal, QColor>(0.0,QColor(255,255,0)));
    initramp.push_back(QPair<qreal, QColor>(10,QColor(0,255,0)));
    initramp.push_back(QPair<qreal, QColor>(50,QColor(0,0,255)));

    // a horizontal ramp
    QColorRampEditor* ramph = new QColorRampEditor(NULL, Qt::Horizontal);
    ramph->setSlideUpdate(true);
    ramph->setMappingTextVisualize(true);
    ramph->setMappingTextColor(Qt::blue);
    ramph->setMappingTextAccuracy(1);
    ramph->setRamp(initramp);

    QObject::connect(ramph, SIGNAL(rampChanged()), dimg, SLOT(onRampChanged()));
    dimg->updateImage(ramph);

    // a vertical ramp
    QColorRampEditor* rampv = new QColorRampEditor(NULL, Qt::Vertical);
    rampv->setSlideUpdate(true);
    rampv->setMappingTextVisualize(true);
    rampv->setMappingTextColor(Qt::black);
    rampv->setMappingTextAccuracy(1);
    rampv->setRamp(initramp);

    QObject::connect(rampv, SIGNAL(rampChanged()), dimg, SLOT(onRampChanged()));
    dimg->updateImage(rampv);

    QWidget* w = new QWidget();    
    QGridLayout* lay = new QGridLayout();
    lay->addWidget(ramph,0,0);
    lay->addWidget(dimg,1,0);
    lay->addWidget(rampv,1,1);
    w->setLayout(lay);    
    w->show();
    w->resize(500,500);
    
    int ret = app.exec();
    w->hide();

    return ret;
}
